//
//  ReDetialTableViewCell.m
//  TravelToHelp
//
//  Created by lanou3g on 15/10/30.
//  Copyright © 2015年 冯贵宾. All rights reserved.
//

#import "ReDetialTableViewCell.h"

@implementation ReDetialTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubviews];
    }
    return self;
}

- (void)addSubviews
{
//    UILabel *titleLB
    self.titleLB = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, kScreenWidth - 20, 30)];
    // self.titleLB.backgroundColor = [UIColor greenColor];
    self.titleLB.font = [UIFont systemFontOfSize:18];
    [self.contentView addSubview:self.titleLB];
//    UIImageView *photoImg;
    self.photoImg = [[UIImageView alloc] initWithFrame:CGRectMake(10, self.titleLB.bottom, kScreenWidth - 20, 150)];
//    self.photoImg.backgroundColor = [UIColor purpleColor];
    [self.contentView addSubview:self.photoImg];
//    UILabel *descriptionLB;
    self.descriptionLB = [[UILabel alloc] initWithFrame:CGRectMake(10, self.photoImg.bottom + 5, kScreenWidth - 20, 105)];
//    self.descriptionLB.backgroundColor = [UIColor cyanColor];
    self.descriptionLB.numberOfLines = 0;
    self.descriptionLB.font = [UIFont systemFontOfSize:14];
    self.descriptionLB.textColor = [UIColor colorWithWhite:0.400 alpha:1.000];
    [self.contentView addSubview:self.descriptionLB];
//    UILabel *trafficLB;
//    self.trafficLB = [[UILabel alloc] initWithFrame:CGRectMake(10, self.descriptionLB.bottom + 5, 40, 20)];
//    self.trafficLB.text = @"交通: ";
//    self.trafficLB.font = [UIFont systemFontOfSize:16];
//    self.trafficLB.textColor = [UIColor grayColor];
//    [self.contentView addSubview:self.trafficLB];
//    UILabel *trafficDetLB;
    self.trafficDetLB = [[UILabel alloc] initWithFrame:CGRectMake(10, self.descriptionLB.bottom, kScreenWidth- 20, 150)];
//    self.trafficDetLB.backgroundColor = [UIColor brownColor];
    self.trafficDetLB.font = [UIFont systemFontOfSize:15];
    self.trafficDetLB.textColor = [UIColor colorWithWhite:0.300 alpha:1.000];
    self.trafficDetLB.numberOfLines = 0;
    [self.contentView addSubview:self.trafficDetLB];
//    UILabel *serveLB;
//    self.serveLB = [[UILabel alloc] initWithFrame:CGRectMake(10, self.trafficDetLB.bottom + 5, 40, 20)];
//    self.serveLB.text = @"贴士: ";
//    self.serveLB.font = [UIFont systemFontOfSize:16];
//    self.serveLB.textColor = [UIColor grayColor];
//    [self.contentView addSubview:self.serveLB];
//    UILabel *serveDetLB;
    self.serveDetLB = [[UILabel alloc] initWithFrame:CGRectMake(10, self.trafficDetLB.bottom, kScreenWidth- 20, 85)];
   // self.serveDetLB.backgroundColor = [UIColor orangeColor];
    self.serveDetLB.font = [UIFont systemFontOfSize:15];
    self.serveDetLB.textColor = [UIColor colorWithWhite:0.300 alpha:1.000];
    self.serveDetLB.numberOfLines = 0;
    [self.contentView addSubview:self.serveDetLB];
}

#pragma mark - 重写set方法进行赋值
- (void)setModel:(FLSFirstHotDetialModel *)model
{
    self.titleLB.text = model.sc_name;
    [self.photoImg sd_setImageWithURL:[NSURL URLWithString:model.cover_picture] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    self.descriptionLB.text = model.content;
    if (model.line.length == 0) {
        self.trafficDetLB.text = [NSString stringWithFormat:@"交通: 详情请咨询当地旅游或相关部门, 感谢您的访问!"];
    } else {
        self.trafficDetLB.text = [NSString stringWithFormat:@"交通: %@", model.line];
    }
    if (model.tips.length == 0) {
        self.serveDetLB.text = [NSString stringWithFormat:@"贴士: 详情请咨询当地旅游或相关部门, 感谢您的访问!"];
    } else {
        self.serveDetLB.text = [NSString stringWithFormat:@"贴士: %@", model.tips];
    }
    
    
}

- (void)adjustSubviewsWithContent:(NSString *)content
{
    //计算活动内容的高度
    CGRect contentRect = [content boundingRectWithSize:CGSizeMake(self.titleLB.width, 1000000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0]} context:nil];
    
//    CGFloat height = _titleLB.top + contentRect.size.height + 20;
//    
//    _bottomScrollView.contentSize = CGSizeMake(320, height);
    
    CGRect contentViewRect = _titleLB.frame;
    contentViewRect.size.height = contentRect.size.height;
    _titleLB.frame = contentViewRect;
    
    
}

@end
